import numpy as np


class Edge:
    def __init__(self, v_from, v_to, value):
        self.v_from, self.v_to, self.value = v_from, v_to, value


class MatrixGraph(np.ndarray):
    def __new__(cls, vexs: list, edges: list, *args, **kwargs):
        obj = np.zeros(shape=[len(vexs), len(vexs)], *args, **kwargs)
        for edge in edges:
            obj[edge.v_from, edge.v_to] = edge.value
        return obj


class ALGraph(np.ndarray):
    def __new__(cls, vexs: list, edges: list, *args, **kwargs):



m = MatrixGraph([0, 1, 2, 3, 4],
                [Edge(0, 1, 2), Edge(1, 3, 5), Edge(0, 2, 3), Edge(2, 4, 6),
                 Edge(3, 2, 4), Edge(3, 4, 1),Edge(4, 1, 7)], dtype=np.int32)
print(m)
